package com.ruoyi.standingbook.v2toilet.report;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.ruoyi.standingbook.v2toilet.ItemEnum;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class MonthReportUtil {
    /**
     * 每天巡检项数据
     *
     * @param originalValue 原始值
     */
    public static void itemDaySummary(final JSONObject originalValue, List<Map<String, String>> rowMap, List<V2ToiletReportBean> monthDay) {
        int maxMonthDay = originalValue.get("days", Integer.class);
        JSONObject listCol = originalValue.get("list", JSONObject.class);
        //行数据
        String k;
        String v;
        for (int i = 1; i <= maxMonthDay; i++) {
            Map<String, String> rowCalc = new LinkedHashMap<>();
            rowCalc.put("row", String.valueOf(i));
            for (ItemEnum item : ItemEnum.values()) {
                k = (item.attr).concat(".d").concat(String.valueOf(i));
                v = listCol.getByPath(k, String.class);
                rowCalc.put(item.attr, StrUtil.isEmpty(v) ? "" : v);
            }
            rowMap.add(rowCalc);
            monthDay.add(new V2ToiletReportBean(i));
        }
    }
}
